//
//  SAPrinterSetting.m
//  Saas
//
//  Created by 杨荣 on 2020/4/14.
//  Copyright © 2020 bing. All rights reserved.
//

#import "SAPrinterSetting.h"

@implementation SAPrinterSetting

static SAPrinterSetting *printerSetting;
+ (SAPrinterSetting *)shareInstance
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        printerSetting = [[SAPrinterSetting alloc] init];
        [printerSetting initData];
    });
    return printerSetting;
}

- (void)initData {
    self.printerName = @"Printer";
    self.printCopies = 1;
    self.printerStatus = 0;
    self.printerBleName = @"";
    self.printTemplateType = 0;
}

// 更新【打印小票排版】
- (void)requestByUpdatePrintTemplateTypeSuccessBlock:(NetworkingSuccessBlock)successBlock
                                             failBlock:(NetworkingFailBlock)failBlock {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setValue:self.printTemplateTypeParentId forKey:@"parentId"];
    [parameters setValue:self.printTemplateTypeSettingId forKey:@"settingsId"];
    [parameters setValue:[NSNumber numberWithInteger:self.printTemplateType] forKey:@"value"];
    [SANetManager requestWithType:(SkyHttpRequestTypePost) urlString:SA_BASE_URL(@"/system/settings/check") parameters:parameters successBlock:^(id responseObject) {
        if (successBlock) {
            successBlock(responseObject);
        }
    } failureBlock:^(NSString *error) {
        if (failBlock) {
            failBlock(error);
        }
    }];
}
// 更新【打印份数】
- (void)requestByUpdatePrintCopiesSuccessBlock:(NetworkingSuccessBlock)successBlock
                                     failBlock:(NetworkingFailBlock)failBlock {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setValue:self.printCopiesParentId forKey:@"parentId"];
    [parameters setValue:self.printCopiesSettingId forKey:@"settingsId"];
    [parameters setValue:[NSNumber numberWithInteger:self.printCopies] forKey:@"value"];
    [SANetManager requestWithType:(SkyHttpRequestTypePost) urlString:SA_BASE_URL(@"/system/settings/check") parameters:parameters successBlock:^(id responseObject) {
        if (successBlock) {
            successBlock(responseObject);
        }
    } failureBlock:^(NSString *error) {
        if (failBlock) {
            failBlock(error);
        }
    }];
}
@end
